<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Operator overloading</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Operator_overloading"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Operator_overloading rootpage-Operator_overloading skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Operator overloading</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p class="mw-empty-elt">
</p>
<style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1126788409">
/* start https://en.wikipedia.org/ */
.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1246091330">
/* start https://en.wikipedia.org/ */
.mw-parser-output .sidebar{width:22em;float:right;clear:right;margin:0.5em 0 1em 1em;background:var(--background-color-neutral-subtle,#f8f9fa);border:1px solid var(--border-color-base,#a2a9b1);padding:0.2em;text-align:center;line-height:1.4em;font-size:88%;border-collapse:collapse;display:table}body.skin-minerva .mw-parser-output .sidebar{display:table!important;float:right!important;margin:0.5em 0 1em 1em!important}.mw-parser-output .sidebar-subgroup{width:100%;margin:0;border-spacing:0}.mw-parser-output .sidebar-left{float:left;clear:left;margin:0.5em 1em 1em 0}.mw-parser-output .sidebar-none{float:none;clear:both;margin:0.5em 1em 1em 0}.mw-parser-output .sidebar-outer-title{padding:0 0.4em 0.2em;font-size:125%;line-height:1.2em;font-weight:bold}.mw-parser-output .sidebar-top-image{padding:0.4em}.mw-parser-output .sidebar-top-caption,.mw-parser-output .sidebar-pretitle-with-top-image,.mw-parser-output .sidebar-caption{padding:0.2em 0.4em 0;line-height:1.2em}.mw-parser-output .sidebar-pretitle{padding:0.4em 0.4em 0;line-height:1.2em}.mw-parser-output .sidebar-title,.mw-parser-output .sidebar-title-with-pretitle{padding:0.2em 0.8em;font-size:145%;line-height:1.2em}.mw-parser-output .sidebar-title-with-pretitle{padding:0.1em 0.4em}.mw-parser-output .sidebar-image{padding:0.2em 0.4em 0.4em}.mw-parser-output .sidebar-heading{padding:0.1em 0.4em}.mw-parser-output .sidebar-content{padding:0 0.5em 0.4em}.mw-parser-output .sidebar-content-with-subgroup{padding:0.1em 0.4em 0.2em}.mw-parser-output .sidebar-above,.mw-parser-output .sidebar-below{padding:0.3em 0.8em;font-weight:bold}.mw-parser-output .sidebar-collapse .sidebar-above,.mw-parser-output .sidebar-collapse .sidebar-below{border-top:1px solid #aaa;border-bottom:1px solid #aaa}.mw-parser-output .sidebar-navbar{text-align:right;font-size:115%;padding:0 0.4em 0.4em}.mw-parser-output .sidebar-list-title{padding:0 0.4em;text-align:left;font-weight:bold;line-height:1.6em;font-size:105%}.mw-parser-output .sidebar-list-title-c{padding:0 0.4em;text-align:center;margin:0 3.3em}@media(max-width:640px){body.mediawiki .mw-parser-output .sidebar{width:100%!important;clear:both;float:none!important;margin-left:0!important;margin-right:0!important}}body.skin--responsive .mw-parser-output .sidebar a>img{max-width:none!important}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sidebar:not(.notheme) .sidebar-list-title,html.skin-theme-clientpref-night .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle{background:transparent!important}html.skin-theme-clientpref-night .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle a{color:var(--color-progressive)!important}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sidebar:not(.notheme) .sidebar-list-title,html.skin-theme-clientpref-os .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle{background:transparent!important}html.skin-theme-clientpref-os .mw-parser-output .sidebar:not(.notheme) .sidebar-title-with-pretitle a{color:var(--color-progressive)!important}}@media print{body.ns-0 .mw-parser-output .sidebar{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><table class="sidebar nomobile nowraplinks" style="width:auto"><tbody><tr><th class="sidebar-title"><a href="Polymorphism_(computer_science)" title="Polymorphism (computer science)">Polymorphism</a></th></tr><tr><th class="sidebar-heading" style="background-color:#ddf;font-size:110%">
<a href="Ad_hoc_polymorphism" title="Ad hoc polymorphism">Ad hoc polymorphism</a></th></tr><tr><td class="sidebar-content plainlist">
<ul><li><a href="Function_overloading" title="Function overloading">Function overloading</a></li>
</ul></td>
</tr><tr><th class="sidebar-heading" style="background-color:#ddf;font-size:110%">
<a href="Parametric_polymorphism" title="Parametric polymorphism">Parametric polymorphism</a></th></tr><tr><td class="sidebar-content plainlist">
<ul><li><a href="Generic_function" title="Generic function">Generic function</a></li>
<li><a href="Generic_programming" title="Generic programming">Generic programming</a></li></ul></td>
</tr><tr><th class="sidebar-heading" style="background-color:#ddf;font-size:110%">
<a href="Subtyping" title="Subtyping">Subtyping</a></th></tr><tr><td class="sidebar-content plainlist">
<ul><li><a href="Virtual_function" title="Virtual function">Virtual function</a></li>
<li><a href="Dynamic_dispatch" title="Dynamic dispatch">Single and dynamic dispatch</a></li>
<li><a href="Double_dispatch" title="Double dispatch">Double dispatch</a></li>
<li><a href="Multiple_dispatch" title="Multiple dispatch">Multiple dispatch</a></li>
<li><a href="Predicate_dispatch" title="Predicate dispatch">Predicate dispatch</a></li></ul></td>
</tr><tr><td class="sidebar-navbar"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}
/* end https://en.wikipedia.org/ */
</style></td></tr></tbody></table>
<p>In <a href="Computer_programming" title="Computer programming">computer programming</a>, <b>operator overloading</b>, sometimes termed <i>operator <a href="Ad_hoc_polymorphism" title="Ad hoc polymorphism">ad hoc polymorphism</a></i>, is a specific case of <a href="Polymorphism_(computer_science)" title="Polymorphism (computer science)">polymorphism</a>, where different <a href="Operator_(computer_programming)" title="Operator (computer programming)">operators</a> have different implementations depending on their arguments. Operator overloading is generally defined by a <a href="Programming_language" title="Programming language">programming language</a>, a <a href="Programmer" title="Programmer">programmer</a>, or both.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Rationale">Rationale </h2></div>
<p>Operator overloading is <a href="Syntactic_sugar" title="Syntactic sugar">syntactic sugar</a>, and is used because it allows programming using notation nearer to the target domain<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> and allows user-defined types a similar level of syntactic support as types built into a language. It is common, for example, in scientific computing, where it allows computing representations of mathematical objects to be manipulated with the same syntax as on paper.
</p><p>Operator overloading does not change the <a href="Expressive_power_(computer_science)" title="Expressive power (computer science)">expressive power</a> of a language (with functions), as it can be emulated using function calls. For example, consider variables <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">a</code>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">b</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">c</code> of some user-defined type, such as <a href="Matrix_(mathematics)" title="Matrix (mathematics)">matrices</a>:
</p><p><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">a + b * c</code>
</p><p>In a language that supports operator overloading, and with the usual assumption that the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">*</code> operator has higher <a href="Order_of_operations" title="Order of operations">precedence</a> than the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">+</code> operator, this is a concise way of writing:
</p><p><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Add(a, Multiply(b, c))</code>
</p><p>However, the former syntax reflects common mathematical usage.
</p>
<div class="mw-heading mw-heading2"><h2 id="Examples">Examples</h2></div>
<p>In this case, the addition operator is overloaded to allow addition on a user-defined type <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Time</code> in <a href="C%2B%2B" title="C++">C++</a>:
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span class="n">Time</span><span class="w"> </span><span class="k">operator</span><span class="o">+</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="n">Time</span><span class="o">&</span><span class="w"> </span><span class="n">lhs</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">Time</span><span class="o">&</span><span class="w"> </span><span class="n">rhs</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">Time</span><span class="w"> </span><span class="n">temp</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">lhs</span><span class="p">;</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">seconds</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">rhs</span><span class="p">.</span><span class="n">seconds</span><span class="p">;</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">minutes</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">seconds</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mi">60</span><span class="p">;</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">seconds</span><span class="w"> </span><span class="o">%=</span><span class="w"> </span><span class="mi">60</span><span class="p">;</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">minutes</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">rhs</span><span class="p">.</span><span class="n">minutes</span><span class="p">;</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">hours</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">minutes</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mi">60</span><span class="p">;</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">minutes</span><span class="w"> </span><span class="o">%=</span><span class="w"> </span><span class="mi">60</span><span class="p">;</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">hours</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">rhs</span><span class="p">.</span><span class="n">hours</span><span class="p">;</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">temp</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>Addition is a <a href="Binary_operation" title="Binary operation">binary operation</a>, which means it has two <a href="Operand" title="Operand">operands</a>. In C++, the arguments being passed are the operands, and the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">temp</code> object is the returned value.
</p><p>The operation could also be defined as a class method, replacing <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">lhs</code> by the hidden <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">this</code> argument; However, this forces the left operand to be of type <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Time</code>:
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span class="c1">// The "const" right before the opening curly brace means that |this| is not modified.</span>
<span class="n">Time</span><span class="w"> </span><span class="n">Time</span><span class="o">::</span><span class="k">operator</span><span class="o">+</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="n">Time</span><span class="o">&</span><span class="w"> </span><span class="n">rhs</span><span class="p">)</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">Time</span><span class="w"> </span><span class="n">temp</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">*</span><span class="k">this</span><span class="p">;</span><span class="w"> </span><span class="c1">// |this| should not be modified, so make a copy.</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">seconds</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">rhs</span><span class="p">.</span><span class="n">seconds</span><span class="p">;</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">minutes</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">seconds</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mi">60</span><span class="p">;</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">seconds</span><span class="w"> </span><span class="o">%=</span><span class="w"> </span><span class="mi">60</span><span class="p">;</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">minutes</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">rhs</span><span class="p">.</span><span class="n">minutes</span><span class="p">;</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">hours</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">minutes</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mi">60</span><span class="p">;</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">minutes</span><span class="w"> </span><span class="o">%=</span><span class="w"> </span><span class="mi">60</span><span class="p">;</span>
<span class="w"> </span><span class="n">temp</span><span class="p">.</span><span class="n">hours</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">rhs</span><span class="p">.</span><span class="n">hours</span><span class="p">;</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">temp</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>Note that a <a href="Unary_operation" title="Unary operation">unary</a> operator defined as a class method would receive no apparent argument (it only works from <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">this</code>):
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span class="kt">bool</span><span class="w"> </span><span class="n">Time</span><span class="o">::</span><span class="k">operator</span><span class="o">!</span><span class="p">()</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">hours</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="o">&&</span><span class="w"> </span><span class="n">minutes</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="o">&&</span><span class="w"> </span><span class="n">seconds</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>The less-than (<) operator is often overloaded to sort a structure or class:
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span class="k">class</span><span class="w"> </span><span class="nc">Pair</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">public</span><span class="o">:</span>
<span class="w"> </span><span class="kt">bool</span><span class="w"> </span><span class="k">operator</span><span class="o"><</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="n">Pair</span><span class="o">&</span><span class="w"> </span><span class="n">p</span><span class="p">)</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">x_</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">x_</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">y_</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">y_</span><span class="p">;</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">x_</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">x_</span><span class="p">;</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="k">private</span><span class="o">:</span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">x_</span><span class="p">;</span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">y_</span><span class="p">;</span>
<span class="p">};</span>
</pre></div>
<p>Like with the previous examples, in the last example operator overloading is done within the class. In C++, after overloading the less-than operator (<), <a href="Sort_(C%2B%2B)" title="Sort (C++)">standard sorting functions</a> can be used to sort some classes.
</p>
<div class="mw-heading mw-heading2"><h2 id="Criticisms">Criticisms</h2></div>
<p>Operator overloading has often been criticized<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> because it allows programmers to reassign the semantics of operators depending on the types of their operands. For example, the use of the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr"><<</code> operator in <a href="C%2B%2B" title="C++">C++</a> <code class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><span class="n">a</span><span class="w"> </span><span class="o"><<</span><span class="w"> </span><span class="n">b</span></code> shifts the bits in the variable <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">a</code> left by <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">b</code> bits if <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">a</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">b</code> are of an integer type, but if <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">a</code> is an output stream then the above code will attempt to write a <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">b</code> to the stream. Because operator overloading allows the original programmer to change the usual semantics of an operator and to catch any subsequent programmers by surprise, it is considered good practice to use operator overloading with care (the creators of <a href="Java_(programming_language)" title="Java (programming language)">Java</a> decided not to use this feature,<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> although not necessarily for this reason).
</p><p>Another, more subtle, issue with operators is that certain rules from mathematics can be wrongly expected or unintentionally assumed. For example, the <a href="Commutative_property" title="Commutative property">commutativity</a> of + (i.e. that <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">a + b == b + a</code>) does not always apply; an example of this occurs when the operands are strings, since + is commonly overloaded to perform a concatenation of strings (i.e. <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">"bird" + "song"</code> yields <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">"birdsong"</code>, while <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">"song" + "bird"</code> yields <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">"songbird"</code>). A typical counter to this argument comes directly from mathematics: While + is commutative on integers (and more generally any complex number), it is not commutative for other "types" of variables. In practice, + is not even always <a href="Operator_associativity" title="Operator associativity">associative</a>, for example with floating-point values due to rounding errors. Another example: In mathematics, multiplication is commutative for real and complex numbers but not commutative in <a href="Matrix_multiplication" title="Matrix multiplication">matrix multiplication</a>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Catalog">Catalog</h2></div>
<p>A classification of some common programming languages is made according to whether their operators are overloadable by the programmer and whether the operators are limited to a predefined set.
</p>
<table class="wikitable">
<tbody><tr>
<th>Operators
</th>
<th>Not overloadable
</th>
<th>Overloadable
</th></tr>
<tr>
<th>New definable<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>
</th>
<td>
<ul><li><a href="ML_(programming_language)" title="ML (programming language)">ML</a></li>
<li><a href="Pico_(programming_language)" title="Pico (programming language)">Pico</a><sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Prolog" title="Prolog">Prolog</a><sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup></li></ul>
</td>
<td>
<ul><li><a href="ALGOL_68#op:_Operators" title="ALGOL 68">ALGOL 68</a></li>
<li><a href="Clojure" title="Clojure">Clojure</a></li>
<li><a href="Eiffel_(programming_language)" title="Eiffel (programming language)">Eiffel</a><sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Fortran" title="Fortran">Fortran</a><sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Futhark_(programming_language)" title="Futhark (programming language)">Futhark</a><sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup></li>
<li><a href="F_Sharp_(programming_language)" title="F Sharp (programming language)">F#</a><sup id="cite_ref-Smith2012_11-0" class="reference"><a href="#cite_note-Smith2012-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Haskell_(programming_language)" class="mw-redirect" title="Haskell (programming language)">Haskell</a><sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Io_(programming_language)" title="Io (programming language)">Io</a><sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Julia_(programming_language)" title="Julia (programming language)">Julia</a><sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Nim_(programming_language)" title="Nim (programming language)">Nim</a><sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup></li>
<li><a href="R_(programming_language)" title="R (programming language)">R</a><sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Raku_(programming_language)" title="Raku (programming language)">Raku</a><sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Scala_(programming_language)" title="Scala (programming language)">Scala</a><sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Seed7" title="Seed7">Seed7</a><sup id="cite_ref-19" class="reference"><a href="#cite_note-19"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Smalltalk" title="Smalltalk">Smalltalk</a><sup id="cite_ref-Hunt2012_20-0" class="reference"><a href="#cite_note-Hunt2012-20"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Swift_(programming_language)" title="Swift (programming language)">Swift</a><sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup></li></ul>
</td></tr>
<tr>
<th>Limited set
</th>
<td>
<ul><li><a href="BASIC" title="BASIC">BASIC</a></li>
<li><a href="C_(programming_language)" title="C (programming language)">C</a></li>
<li><a href="Go_(programming_language)" title="Go (programming language)">Go</a><sup id="cite_ref-22" class="reference"><a href="#cite_note-22"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Java_(programming_language)" title="Java (programming language)">Java</a></li>
<li><a href="JavaScript" title="JavaScript">JavaScript</a></li>
<li><a href="Modula-2" title="Modula-2">Modula-2</a></li>
<li><a href="Objective-C" title="Objective-C">Objective-C</a></li>
<li><a href="Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a><sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup></li>
<li><a href="TypeScript" title="TypeScript">TypeScript</a><sup id="cite_ref-24" class="reference"><a href="#cite_note-24"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Visual_Basic" title="Visual Basic">Visual Basic</a></li></ul>
</td>
<td>
<ul><li><a href="Ada_(programming_language)" title="Ada (programming language)">Ada</a><sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup></li>
<li><a href="C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a><sup id="cite_ref-DraytonAlbahari2003_26-0" class="reference"><a href="#cite_note-DraytonAlbahari2003-26"><span class="cite-bracket">[</span>26<span class="cite-bracket">]</span></a></sup></li>
<li><a href="C%2B%2B" title="C++">C++</a><sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Ceylon_(programming_language)" title="Ceylon (programming language)">Ceylon</a><sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">[</span>28<span class="cite-bracket">]</span></a></sup></li>
<li><a href="D_(programming_language)" title="D (programming language)">D</a><sup id="cite_ref-29" class="reference"><a href="#cite_note-29"><span class="cite-bracket">[</span>29<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Dart_(programming_language)" title="Dart (programming language)">Dart</a><sup id="cite_ref-30" class="reference"><a href="#cite_note-30"><span class="cite-bracket">[</span>30<span class="cite-bracket">]</span></a></sup></li>
<li><a href="FreeBASIC" title="FreeBASIC">FreeBASIC</a><sup id="cite_ref-31" class="reference"><a href="#cite_note-31"><span class="cite-bracket">[</span>31<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Groovy_(programming_language)" class="mw-redirect" title="Groovy (programming language)">Groovy</a><sup id="cite_ref-32" class="reference"><a href="#cite_note-32"><span class="cite-bracket">[</span>32<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Kotlin_(programming_language)" title="Kotlin (programming language)">Kotlin</a><sup id="cite_ref-33" class="reference"><a href="#cite_note-33"><span class="cite-bracket">[</span>33<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Lua_(programming_language)" class="mw-redirect" title="Lua (programming language)">Lua</a><sup id="cite_ref-34" class="reference"><a href="#cite_note-34"><span class="cite-bracket">[</span>34<span class="cite-bracket">]</span></a></sup></li>
<li><a href="MATLAB" title="MATLAB">MATLAB</a><sup id="cite_ref-35" class="reference"><a href="#cite_note-35"><span class="cite-bracket">[</span>35<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Object_Pascal" title="Object Pascal">Object Pascal</a> (<a href="Free_Pascal" title="Free Pascal">Free Pascal</a>,<sup id="cite_ref-36" class="reference"><a href="#cite_note-36"><span class="cite-bracket">[</span>36<span class="cite-bracket">]</span></a></sup> <a href="Delphi_(programming_language)" class="mw-redirect" title="Delphi (programming language)">Delphi</a> (since 2005)<sup id="cite_ref-37" class="reference"><a href="#cite_note-37"><span class="cite-bracket">[</span>37<span class="cite-bracket">]</span></a></sup>)</li>
<li><a href="PHP" title="PHP">PHP</a> (using magic methods,<sup id="cite_ref-38" class="reference"><a href="#cite_note-38"><span class="cite-bracket">[</span>38<span class="cite-bracket">]</span></a></sup> ArrayAccess interface, or Operator extension)</li>
<li><a href="Perl" title="Perl">Perl</a><sup id="cite_ref-Orwant2002_39-0" class="reference"><a href="#cite_note-Orwant2002-39"><span class="cite-bracket">[</span>39<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Python_(programming_language)" title="Python (programming language)">Python</a><sup id="cite_ref-40" class="reference"><a href="#cite_note-40"><span class="cite-bracket">[</span>40<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a><sup id="cite_ref-41" class="reference"><a href="#cite_note-41"><span class="cite-bracket">[</span>41<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Rust_(programming_language)" title="Rust (programming language)">Rust</a><sup id="cite_ref-42" class="reference"><a href="#cite_note-42"><span class="cite-bracket">[</span>42<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Visual_Basic_.NET" class="mw-redirect" title="Visual Basic .NET">Visual Basic .NET</a><sup id="cite_ref-43" class="reference"><a href="#cite_note-43"><span class="cite-bracket">[</span>43<span class="cite-bracket">]</span></a></sup></li></ul>
</td></tr></tbody></table>
<div class="mw-heading mw-heading2"><h2 id="Timeline_of_operator_overloading">Timeline of operator overloading</h2></div>
<div class="mw-heading mw-heading3"><h3 id="1960s">1960s</h3></div>
<p>The <a href="ALGOL_68" title="ALGOL 68">ALGOL 68</a> specification allowed operator overloading.<sup id="cite_ref-44" class="reference"><a href="#cite_note-44"><span class="cite-bracket">[</span>44<span class="cite-bracket">]</span></a></sup>
</p><p>Extract from the ALGOL 68 language specification (page 177) where the overloaded operators ¬, =, ≠, and <b>abs</b> are defined:
</p>
<pre>10.2.2. Operations on Boolean Operands
a) <b>op</b> ∨ = (<b>bool</b> a, b) <b>bool</b>:( a | <b>true</b> | b );
b) <b>op</b> ∧ = (<b>bool</b> a, b) <b>bool</b>: ( a | b | <b>false</b> );
c) <b>op</b> ¬ = (<b>bool</b> a) <b>bool</b>: ( a | <b>false</b> | <b>true</b> );
d) <b>op</b> = = (<b>bool</b> a, b) <b>bool</b>:( a∧b ) ∨ ( ¬b∧¬a );
e) <b>op</b> ≠ = (<b>bool</b> a, b) <b>bool</b>: ¬(a=b);
f) <b>op</b> <b>abs</b> = (<b>bool</b> a)<b>int</b>: ( a | 1 | 0 );
</pre>
<p>Note that no special declaration is needed to <i>overload</i> an operator, and the programmer is free to create new operators. For dyadic operators their priority compared to other operators can be set:
</p>
<pre> <b>prio</b> <b>max</b> = 9;
<b>op</b> <b>max</b> = (<b>int</b> a, b) <b>int</b>: ( a>b | a | b );
<b>op</b> <b>++</b> = ( <b>ref</b> <b>int</b> a ) <b>int</b>: ( a +:= 1 );
</pre>
<div class="mw-heading mw-heading3"><h3 id="1980s">1980s</h3></div>
<p><a href="Ada_(programming_language)" title="Ada (programming language)">Ada</a> supports overloading of operators from its inception, with the publication of the Ada 83 language standard. However, the language designers chose to preclude the definition of new operators. Only extant operators in the language may be overloaded, by defining new functions with identifiers such as "+", "*", "&" etc. Subsequent revisions of the language (in 1995 and 2005) maintain the restriction to overloading of extant operators.
</p><p>In <a href="C%2B%2B" title="C++">C++</a>, operator overloading is more refined than in <a href="ALGOL_68" title="ALGOL 68">ALGOL 68</a>.<sup id="cite_ref-45" class="reference"><a href="#cite_note-45"><span class="cite-bracket">[</span>45<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="1990s">1990s</h3></div>
<p><a href="Java_(programming_language)" title="Java (programming language)">Java</a> language designers at <a href="Sun_Microsystems" title="Sun Microsystems">Sun Microsystems</a> chose to omit overloading.<sup id="cite_ref-46" class="reference"><a href="#cite_note-46"><span class="cite-bracket">[</span>46<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-47" class="reference"><a href="#cite_note-47"><span class="cite-bracket">[</span>47<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-48" class="reference"><a href="#cite_note-48"><span class="cite-bracket">[</span>48<span class="cite-bracket">]</span></a></sup>
</p><p><a href="Python_(programming_language)" title="Python (programming language)">Python</a> allows operator overloading through the implementation of methods with special names.<sup id="cite_ref-49" class="reference"><a href="#cite_note-49"><span class="cite-bracket">[</span>49<span class="cite-bracket">]</span></a></sup> For example, the addition (+) operator can be overloaded by implementing the method <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">obj.__add__(self, other)</code>.
</p><p><a href="Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a> allows operator overloading as syntactic sugar for simple method calls.
</p><p><a href="Lua_(programming_language)" class="mw-redirect" title="Lua (programming language)">Lua</a> allows operator overloading as syntactic sugar for method calls with the added feature that if the first operand doesn't define that operator, the method for the second operand will be used.
</p>
<div class="mw-heading mw-heading3"><h3 id="2000s">2000s</h3></div>
<p>Microsoft added operator overloading to <a href="C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a> in 2001 and to <a href="Visual_Basic_.NET" class="mw-redirect" title="Visual Basic .NET">Visual Basic .NET</a> in 2003.
</p><p><a href="Scala_(programming_language)" title="Scala (programming language)">Scala</a> treats all operators as methods and thus allows operator overloading by proxy.
</p><p>In <a href="Raku_(programming_language)" title="Raku (programming language)">Raku</a>, the definition of all operators is delegated to lexical functions, and so, using function definitions, operators can be overloaded or new operators added. For example, the function defined in the <a href="Rakudo" title="Rakudo">Rakudo</a> source for incrementing a Date object with "+" is:
</p>
<div class="mw-highlight mw-highlight-lang-perl6 mw-content-ltr" dir="ltr"><pre><span class="k">multi</span> <span class="nb">infix:<+></span>(<span class="nb">Date:D</span> <span class="nv">$d</span>, <span class="nb">Int:D</span> <span class="nv">$x</span>) {
<span class="nb">Date</span>.<span class="nb">new-from-daycount</span>(<span class="nv">$d</span>.<span class="nb">daycount</span> + <span class="nv">$x</span>)
}
</pre></div>
<p>Since "multi" was used, the function gets added to the list of <a href="Multidispatch" class="mw-redirect" title="Multidispatch">multidispatch</a> candidates, and "+" is only overloaded for the case where the type constraints in the function signature are met.
While the capacity for overloading includes <b>+</b>, <b>*</b>, <b>>=</b>, the <a href="Imaginary_unit" title="Imaginary unit">postfix and term <b>i</b></a>, and so on, it also allows for overloading various brace operators: "<b>[</b>x, y<b>]</b>", "x<b>[</b>y<b>]</b>", "x<b>{<i>y</i>}</b>", and "x<b>(</b>y<b>)</b>".
</p><p><a href="Kotlin_(programming_language)" title="Kotlin (programming language)">Kotlin</a> has supported operator overloading since its creation.
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Function_overloading" title="Function overloading">Function overloading</a></li>
<li><a href="Polymorphism_(computer_science)" title="Polymorphism (computer science)">Polymorphism (computer science)</a></li>
<li><a href="Subroutine" class="mw-redirect" title="Subroutine">Subroutine</a></li>
<li><a href="Operator_(programming)" class="mw-redirect" title="Operator (programming)">Operator (programming)</a></li>
<li><a href="Operators_in_C_and_C%2B%2B" title="Operators in C and C++">Operators in C and C++</a></li>
<li><a href="Mutator_method" title="Mutator method">Mutator method</a></li>
<li><a href="Indexer_(programming)" title="Indexer (programming)">Indexer (programming)</a></li>
<li><a href="Property_(programming)" title="Property (programming)">Property (programming)</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist reflist-columns references-column-width" style="column-width: 30em;">
<ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFStroustrup" class="citation web cs1"><a href="Bjarne_Stroustrup" title="Bjarne Stroustrup">Stroustrup, Bjarne</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20110814105309/http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-13.2">"Operator Overloading"</a>. <i>C++ FAQ</i>. Archived from <a rel="nofollow" class="external text" href="https://isocpp.org/wiki/faq/operator-overloading#op-ov-benefits">the original</a> on 14 August 2011<span class="reference-accessdate">. Retrieved <span class="nowrap">27 August</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><cite id="CITEREFFisher2008" class="citation web cs1">Fisher, Charles N. (2008). <a rel="nofollow" class="external text" href="http://pages.cs.wisc.edu/~fischer/cs538.s08/lectures/Lecture08.4up.pdf">"Issues in Overloading"</a> <span class="cs1-format">(PDF)</span>. <a href="University_of_Wisconsin%E2%80%93Madison" title="University of Wisconsin–Madison">University of Wisconsin–Madison</a>.</cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.oracle.com/technetwork/java/simple-142616.html#4098">"No more operator overloading"</a>. <i>The Java Language Environment</i>. <a href="Oracle_Corporation" title="Oracle Corporation">Oracle Corporation</a>.</cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text">Completely new operators can be added.</span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text">Binary functions with a symbolic name can be called infix.</span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.swi-prolog.org/pldoc/man?predicate=op/3">"Predicate op/3"</a>.</cite></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://se.ethz.ch/~meyer/publications/online/eiffel/basic.html">"Bertrand Meyer: Basic Eiffel language mechanisms"</a>. <i>se.ethz.ch</i><span class="reference-accessdate">. Retrieved <span class="nowrap">7 April</span> 2021</span>.</cite></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.mathcs.emory.edu/~cheung/Courses/561/Syllabus/6-Fortran/operators.html">"Operator functions in F90"</a>. <i>www.mathcs.emory.edu</i><span class="reference-accessdate">. Retrieved <span class="nowrap">7 April</span> 2021</span>.</cite></span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text">Introduced in Fortran 90.</span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://futhark.readthedocs.io/en/latest/language-reference.html">"3. Language Reference — Futhark 0.19.0 documentation"</a>. <i>futhark.readthedocs.io</i><span class="reference-accessdate">. Retrieved <span class="nowrap">10 October</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-Smith2012-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-Smith2012_11-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFSmith2012" class="citation book cs1">Smith, Chris (9 October 2012). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=e0Wl6id4unQC&q=%22operator+overloading%22"><i>Programming F# 3.0: A Comprehensive Guide for Writing Simple Code to Solve Complex Problems</i></a>. O'Reilly Media, Inc. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-1-4493-2604-3</bdi>.</cite></span>
</li>
<li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><a href="Type_class" title="Type class">Type classes</a> instead of overloading.</span>
</li>
<li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://iolanguage.org/guide/guide.html#Syntax-Operators">"io guide"</a>. <i>iolanguage.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">7 April</span> 2021</span>.</cite></span>
</li>
<li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.geeksforgeeks.org/operator-overloading-in-julia/">"Operator Overloading in Julia"</a>. <i>geeksforgeeks.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">14 March</span> 2025</span>.</cite></span>
</li>
<li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://nim-lang.github.io/Nim/tut1.html#procedures-operators">"Operators"</a>.</cite></span>
</li>
<li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.oreilly.com/library/view/r-in-a/9781449358204/ch06s02.html">"Operators - R in a Nutshell, 2nd Edition [Book]"</a>. <i>www.oreilly.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">7 April</span> 2021</span>.</cite></span>
</li>
<li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.raku.org/language/optut">"Creating operators"</a>.</cite></span>
</li>
<li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.scala-lang.org/tour/operators.html">"Operators"</a>. <i>Tour of Scala</i>.</cite></span>
</li>
<li id="cite_note-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-19">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://seed7.sourceforge.net/manual/syntax.htm">"Seed7 Manual: Structured syntax definition"</a>. <i>seed7.sourceforge.net</i><span class="reference-accessdate">. Retrieved <span class="nowrap">29 September</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-Hunt2012-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-Hunt2012_20-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFHunt2012" class="citation book cs1">Hunt, John (6 December 2012). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=BiDUBwAAQBAJ&q=overloading+operators"><i>Smalltalk and Object Orientation: An Introduction</i></a>. Springer Science & Business Media. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-1-4471-0961-7</bdi>.</cite></span>
</li>
<li id="cite_note-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-21">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.swift.org/swift-book/LanguageGuide/AdvancedOperators.html">"Swift: Advanced Operators"</a>.</cite></span>
</li>
<li id="cite_note-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-22">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://golang.org/doc/go_faq.html#overloading">"Why does Go not support overloading of methods and operators?"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">4 September</span> 2011</span>.</cite></span>
</li>
<li id="cite_note-23"><span class="mw-cite-backlink"><b><a href="#cite_ref-23">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.freepascal.org/docs-html/ref/refse101.html#x213-23500015.1">"Introduction"</a>. <i>freepascal.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">30 September</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-24">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/Microsoft/TypeScript/issues/5407">"Operator Overloads"</a>. <i><a href="GitHub" title="GitHub">GitHub</a></i><span class="reference-accessdate">. Retrieved <span class="nowrap">28 September</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-25"><span class="mw-cite-backlink"><b><a href="#cite_ref-25">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.adaic.org/resources/add_content/standards/05aarm/html/AA-6-6.html">"6.6 Overloading of Operators"</a>. <i>Annotated Ada Reference Manual</i>.</cite></span>
</li>
<li id="cite_note-DraytonAlbahari2003-26"><span class="mw-cite-backlink"><b><a href="#cite_ref-DraytonAlbahari2003_26-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFDraytonAlbahariNeward2003" class="citation book cs1">Drayton, Peter; Albahari, Ben; Neward, Ted (2003). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=bG_Aqb6iOUYC&q=%22operator+overloading%22"><i>C# in a Nutshell</i></a>. O'Reilly Media, Inc. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-596-00526-9</bdi>.</cite></span>
</li>
<li id="cite_note-27"><span class="mw-cite-backlink"><b><a href="#cite_ref-27">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://en.cppreference.com/w/cpp/language/operators">"C++ Operator Overloading"</a>.</cite></span>
</li>
<li id="cite_note-28"><span class="mw-cite-backlink"><b><a href="#cite_ref-28">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://ceylon-lang.org/documentation/1.3/reference/operator/operator-polymorphism/">"Eclipse Ceylon: Operator Polymorphism"</a>. <i>ceylon-lang.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">7 April</span> 2021</span>.</cite></span>
</li>
<li id="cite_note-29"><span class="mw-cite-backlink"><b><a href="#cite_ref-29">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://dlang.org/spec/operatoroverloading.html">"Operator Overloading - D Programming Language"</a>. <i>dlang.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">10 October</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-30"><span class="mw-cite-backlink"><b><a href="#cite_ref-30">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://dart.dev/guides/language/language-tour">"A tour of the Dart language"</a>. <i>dart.dev</i><span class="reference-accessdate">. Retrieved <span class="nowrap">30 September</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-31"><span class="mw-cite-backlink"><b><a href="#cite_ref-31">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://bourabai.kz/einf/freebasic/ProPgOperatorOverloading.html">"Operator Overloading"</a>. <i>bourabai.kz</i><span class="reference-accessdate">. Retrieved <span class="nowrap">7 April</span> 2021</span>.</cite></span>
</li>
<li id="cite_note-32"><span class="mw-cite-backlink"><b><a href="#cite_ref-32">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://groovy-lang.org/operators.html#Operator-Overloading">"The Apache Groovy programming language - Operators"</a>. <i>groovy-lang.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">30 September</span> 2020</span>.</cite></span>
</li>
<li id="cite_note-33"><span class="mw-cite-backlink"><b><a href="#cite_ref-33">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://kotlinlang.org/docs/reference/operator-overloading.html">"Operator overloading"</a>. <i>Kotlin</i><span class="reference-accessdate">. Retrieved <span class="nowrap">24 June</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-34"><span class="mw-cite-backlink"><b><a href="#cite_ref-34">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://lua-users.org/wiki/MetamethodsTutorial">"Metamethods Tutorial"</a>. <i>Lua-users Wiki</i>.</cite></span>
</li>
<li id="cite_note-35"><span class="mw-cite-backlink"><b><a href="#cite_ref-35">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.mathworks.com/help/matlab/matlab_oop/implementing-operators-for-your-class.html">"Implementing Operators for Your Class"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">1 October</span> 2013</span>.</cite></span>
</li>
<li id="cite_note-36"><span class="mw-cite-backlink"><b><a href="#cite_ref-36">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.freepascal.org/docs-html/ref/refch15.html">"Operator Overloading"</a>. <i>Free Pascal Manual</i><span class="reference-accessdate">. Retrieved <span class="nowrap">1 December</span> 2014</span>.</cite></span>
</li>
<li id="cite_note-37"><span class="mw-cite-backlink"><b><a href="#cite_ref-37">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://docwiki.embarcadero.com/RADStudio/XE4/en/Operator_Overloading_%28Delphi%29">"Operator Overloading"</a>. <i>Delphi Manual</i><span class="reference-accessdate">. Retrieved <span class="nowrap">1 December</span> 2014</span>.</cite></span>
</li>
<li id="cite_note-38"><span class="mw-cite-backlink"><b><a href="#cite_ref-38">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20160304050243/http://webwidetutor.com/php/php-oop-Magic-Methods-tutorial-?id=30">"PHP magic methods overriding class properties"</a>. Archived from <a rel="nofollow" class="external text" href="http://webwidetutor.com/php/php-oop-Magic-Methods-tutorial-?id=30">the original</a> on 4 March 2016<span class="reference-accessdate">. Retrieved <span class="nowrap">7 April</span> 2015</span>.</cite></span>
</li>
<li id="cite_note-Orwant2002-39"><span class="mw-cite-backlink"><b><a href="#cite_ref-Orwant2002_39-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFOrwant2002" class="citation book cs1">Orwant, Jon (4 November 2002). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=8TkEOyBHoOoC&q=%22operator+overloading%22&pg=PA347"><i>Computer Science & Perl Programming: Best of The Perl Journal</i></a>. O'Reilly Media, Inc. pp. 347–. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-596-00310-4</bdi>.</cite></span>
</li>
<li id="cite_note-40"><span class="mw-cite-backlink"><b><a href="#cite_ref-40">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.python.org/3/reference/datamodel.html">"3. Data Model"</a>. <i>The Python Language Reference</i>.</cite></span>
</li>
<li id="cite_note-41"><span class="mw-cite-backlink"><b><a href="#cite_ref-41">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.ruby-lang.org/en/documentation/faq/7/">"Methods"</a>. <i>Official Ruby FAQ</i>.</cite></span>
</li>
<li id="cite_note-42"><span class="mw-cite-backlink"><b><a href="#cite_ref-42">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://doc.rust-lang.org/stable/rust-by-example/trait/ops.html">"Operator Overloading"</a>. <i>Rust By Example</i>.</cite></span>
</li>
<li id="cite_note-43"><span class="mw-cite-backlink"><b><a href="#cite_ref-43">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/how-to-define-an-operator">"How to: Define an Operator (Visual Basic)"</a>. 15 September 2021.</cite></span>
</li>
<li id="cite_note-44"><span class="mw-cite-backlink"><b><a href="#cite_ref-44">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.softwarepreservation.org/projects/ALGOL/report/Algol68_revised_report-AB-600dpi.pdf">=Barry J. Mailloux "Report on the Algorithmic Language ALGOL 68, Section 10.2.2"</a>. August 1968<span class="reference-accessdate">. Retrieved <span class="nowrap">1 April</span> 2007</span>.</cite> <span class="cs1-visible-error citation-comment"><code class="cs1-code">{{cite web}}</code>: </span><span class="cs1-visible-error citation-comment">Check <code class="cs1-code">|url=</code> value (help)</span></span>
</li>
<li id="cite_note-45"><span class="mw-cite-backlink"><b><a href="#cite_ref-45">^</a></b></span> <span class="reference-text"><cite id="CITEREFStroustrup" class="citation web cs1"><a href="Bjarne_Stroustrup" title="Bjarne Stroustrup">Stroustrup, Bjarne</a>. <a rel="nofollow" class="external text" href="http://www.stroustrup.com/hopl2.pdf">"A History of C++: 1979−1991"</a> <span class="cs1-format">(PDF)</span>. p. 12<span class="reference-accessdate">. Retrieved <span class="nowrap">1 April</span> 2007</span>.</cite></span>
</li>
<li id="cite_note-46"><span class="mw-cite-backlink"><b><a href="#cite_ref-46">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.cafeaulait.org/javafaq.html#xtocid1902938">"FAQ Question 6.9: Why isn't there operator overloading?"</a>. <i>The comp.lang.java FAQ List</i>.</cite></span>
</li>
<li id="cite_note-47"><span class="mw-cite-backlink"><b><a href="#cite_ref-47">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20090307035128/http://java.sun.com/docs/white/langenv/Simple.doc2.html">"java.sun.com"</a>. Archived from <a rel="nofollow" class="external text" href="http://java.sun.com/docs/white/langenv/Simple.doc2.html">the original</a> on 7 March 2009<span class="reference-accessdate">. Retrieved <span class="nowrap">26 March</span> 2009</span>.</cite></span>
</li>
<li id="cite_note-48"><span class="mw-cite-backlink"><b><a href="#cite_ref-48">^</a></b></span> <span class="reference-text"><cite id="CITEREFHolzner2001" class="citation book cs1">Holzner, Steven (2001). <i>C++: Black Book</i>. Scottsdale, Arizona: Coriolis Group. p. 387. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>1-57610-777-9</bdi>. <q>One of the nicest features of C++ OOP is that you can overload operators to handle objects of your classes (you can't do this in some other OOP-centric languages, like Java).</q></cite></span>
</li>
<li id="cite_note-49"><span class="mw-cite-backlink"><b><a href="#cite_ref-49">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.python.org/3/reference/datamodel.html#specialnames">"3. Data Model, Special method names"</a>. <i>The Python Language Reference</i>.</cite></span>
</li>
</ol></div>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox authority-control" aria-label="Navbox390" style="padding:3px"><table class="nowraplinks hlist navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="row" class="navbox-group" style="width:1%">Authority control databases: National </th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"><ul><li><span class="uid"><a rel="nofollow" class="external text" href="https://d-nb.info/gnd/4531051-8">Germany</a></span></li></ul></div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-03-14" href="https://en.wikipedia.org/wiki/?title=Operator_overloading&oldid=1280395211">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>